//package com.gk.panda.apis.util.excel;
//
//import com.alibaba.excel.EasyExcel;
//import com.alibaba.excel.ExcelReader;
//import com.alibaba.excel.ExcelWriter;
//import com.alibaba.excel.read.builder.ExcelReaderBuilder;
//import com.alibaba.excel.write.builder.ExcelWriterBuilder;
//import com.alibaba.excel.write.metadata.WriteSheet;
//
//import java.io.InputStream;
//import java.io.OutputStream;
//import java.util.List;
//
//public class ExcelUtil {
//
//    private static final int MAX_COUNT_PER_SHEET = 5000;
//
//    public static <T> void importExcal(InputStream is, Class<T> clazz, BatchJob<T> batchJob){
//        ExcalReadListener<T> listener = new ExcalReadListener<>(batchJob);
//        ExcelReaderBuilder readerBuilder = EasyExcel.read(is, clazz, listener);
//        ExcelReader reader = readerBuilder.build();
//        reader.readAll();
//        listener.finishBatchProcess();
//    }
//
//    public static <T> void exportExcal(OutputStream os, String sheetName, Class<T> clazz, List<T> dataList){
//        int total = dataList.size();
//        int sheetCount = total/MAX_COUNT_PER_SHEET;
//        if (total%MAX_COUNT_PER_SHEET>0){
//            sheetCount++;
//        }
//        ExcelWriterBuilder writerBuilder = EasyExcel.write(os, clazz);
//        ExcelWriter writer = writerBuilder.build();
//        for (int i = 0; i < sheetCount; i++) {
//            int start = i*MAX_COUNT_PER_SHEET;
//            int end = (i+1)*MAX_COUNT_PER_SHEET;
//            if (end>total) end=total;
//            List<T> sheetData = dataList.subList(start, end);
//            WriteSheet sheet = new WriteSheet();
//            sheet.setSheetNo(i);
//            sheet.setSheetName(sheetName+i);
//            writer.write(sheetData,sheet);
//        }
//        writer.finish();
//    }
//}
